import 'package:casdon/core/logger/log.dart';
import 'package:casdon/core/network/business_exception.dart';
import 'package:casdon/modules/device/data/api/ciot_product_category_api.dart';
import 'package:casdon/modules/device/data/repository/device_repository.dart';

class CiotProductCategoryUsecase {
  final DeviceRepository _repository;

  const CiotProductCategoryUsecase(this._repository);

  Future<List<ResponseCiotProductCategoryApi>> execute() async {
    try {
      var ret = await _repository.getCiotProductCategory();
      ret ??= [];
      return ret;
    } on BusinessException {
      rethrow;
    } catch (e) {
      Log.e("CiotProductCategoryUsecase 失败", e.toString(), StackTrace.current);
      throw Exception("CiotProductCategoryUsecase 失败");
    }
  }
}
